<!--
 * @Author: your name
 * @Date: 2020-11-02 11:43:26
 * @LastEditTime: 2020-12-09 14:10:45
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \sende_nuxt\pages\purchaseLens\index.vue
-->
<template>
  <div class="purchaseLens w1200auto">
      <part-back class="mb20" />
      <part-title class="mb20" titleTxt="Prescription type" numList="1." />
      <part-type class="mb60" :configType="configType" @changeType="changeType" />
      <part-title class="mb20" titleTxt="purchaseLens.Choose lenses" numList="2." />
      <choose-lenses class="mb80" :configLenses="configLenses" @getPrice="getPrice" />
      <part-title class="mb20" titleTxt="purchaseLens.Enter your prescription" numList="3." v-if="lensesIndex !== 1" />
      <prescription-option class="mb40" :typeIndex="lensesIndex" v-if="lensesIndex !== 1"/>
      <add-to-cart />
  </div>
</template>
 
<script>
import PartBack from '~/components/purchaseLens/PartBack';
import PartTitle from '~/components/purchaseLens/PartTitle';
import PartType from '~/components/purchaseLens/PartType';
import ChooseLenses from '~/components/purchaseLens/ChooseLenses';
import PrescriptionOption from '~/components/purchaseLens/PrescriptionOption';
import addToCart from '~/components/purchaseLens/addToCart';
export default {
    asyncData: ({app}) => {
        const configLensesData = [
            [
            {
                title: 'Clear',
                img: require('../../assets/image/chooseLenses_img_1.jpg'),
                config: [
                    {
                        price: 99,
                        isChecked: '1',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 9,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
            ,{
                title: 'Blue light blocking',
                img: require('../../assets/image/chooseLenses_img_2.jpg'),
                config: [
                    {
                        price: 99,
                        isChecked: '1',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 9,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
            ,{
                title: 'Polarised and Tint',
                img: require('../../assets/image/chooseLenses_img_3.jpg'),
                config: [
                    {
                        price: 99,
                        isChecked: '1',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 9,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
            ,{
                title: 'Photochromic',
                img:  require('../../assets/image/chooseLenses_img_4.jpg'),
                config: [
                    {
                        price: 99,
                        isChecked: '0',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 9,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '1',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
        ]
            ,[
            {
                title: 'Clear',
                img: require('../../assets/image/chooseLenses_img_1.jpg'),
                config: [
                    {
                        price: 199,
                        isChecked: '1',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 199,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
            ,{
                title: 'Blue light blocking',
                img: require('../../assets/image/chooseLenses_img_2.jpg'),
                config: [
                    {
                        price: 99,
                        isChecked: '1',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 9,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
            ,{
                title: 'Polarised and Tint',
                img: require('../../assets/image/chooseLenses_img_3.jpg'),
                config: [
                    {
                        price: 99,
                        isChecked: '1',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 9,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
            ,{
                title: 'Photochromic',
                img:  require('../../assets/image/chooseLenses_img_4.jpg'),
                config: [
                    {
                        price: 99,
                        isChecked: '0',
                        isRecommend: '1',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_1.jpg'),
                    }
                    ,{
                        price: 9,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_2.jpg'),
                    }
                    ,{
                        price: 99,
                        isChecked: '0',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_3.jpg'),
                    }
                    ,{
                        price: 109,
                        isChecked: '1',
                        isRecommend: '0',
                        txt: '1.61 refractive index photochromic anti-blue light aspheric surface',
                        img: require('../../assets/image/chooseLenses_img_4.jpg'),
                    }
                ]
            }
        ]
        ]
        const configType = [
            {
                title: 'Single Vision',
                desc: 'corrects near or farsightedness'
            },
            {
                title: 'Non Prescription',
                desc: 'corrects near or farsightedness'
            },
            {
                title: 'Progressive (No-Line)',
                desc: 'corrects near or farsightedness'
            },
            {
                title: 'Frame Only',
                desc: 'corrects near or farsightedness'
            },
        ]
        return {
            configLenses: configLensesData[0],
            configType: configType,
            configLensesData: configLensesData,
            lensesIndex: 0
        }
    },
    components: {
        PartBack,
        PartTitle,
        PartType,
        ChooseLenses,
        PrescriptionOption,
        addToCart
    },
    methods: {
        getPrice(price) {
            console.log('price :>> ', price);
        },
        changeType(index) {
            if (index !== 3) {
                this.configLenses = this.configLensesData[index];
                // 目前暂时用索引来判断，后续用类型型号来判断
                this.lensesIndex = index;
            } else {
                this.$router.push('/cart');
            }
        }
    }
}
</script>

<style lang="scss" scoped>

</style>